package com.administrator.customviewtest.other.single;

/**
 * Created by lsp on 2017/8/29 10 09
 */

public class LazySingleton {
    private static LazySingleton lazySingleton;
    private LazySingleton(){

    }
    //方式1
    public static synchronized LazySingleton getInstance(){
        if (lazySingleton==null) {
            lazySingleton=new LazySingleton();
        }
        return lazySingleton;
    }
    public static LazySingleton getLazySingleton(){
        synchronized (LazySingleton.class){
            if (lazySingleton==null){
                lazySingleton = new LazySingleton();
            }
            return lazySingleton;
        }
    }
}
